package com.ssm.zy.common.controller;

import com.ssm.zy.common.result.Result;
import com.ssm.zy.common.result.ResultCode;
import com.ssm.zy.utils.OSSUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 郑智辰~
 * @version 1.0
 *
 * 公共的Controller(用于一些公用的请求接口，如：上传文件)
 */
@CrossOrigin
@RestController
@RequestMapping("/common")
public class CommonController extends BaseController {

    @PostMapping("/fileUpload")
    public Result<String> getFileUploadPath(@RequestParam("file") MultipartFile file) throws IOException {
        String filePath = OSSUtil.storageFile(file);
        return new Result<String>(ResultCode.SUCCESS, filePath);
    }

}
